import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:mtf/R.dart';
import 'package:mtf/app/modules/notice_list_module/notice_list_controller.dart';
import 'package:mtf/app/theme/app_colors.dart';
import 'package:mtf/app/widget/AppBarLeftTitle.dart';
import 'package:mtf/app/widget/SettingBar.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import '../../utils/AppUtils.dart';
/**
 * GetX Template Generator - fb.com/htngu.99
 * */

class noticeListPage extends GetView<noticeListController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarLeftTitle(title: "公告"),
      body: RefreshConfiguration(
        headerBuilder: () => ClassicHeader(),
        footerBuilder: () => ClassicFooter(),
        child: SmartRefresher(
          controller: controller.refreshController,
          enablePullDown: true,
          enablePullUp: true,
          onRefresh: () {
            controller.refresh();
          },
          onLoading: () {
            controller.load();
          },
          child: Obx(() {
            return ListView.builder(
              physics: NeverScrollableScrollPhysics(),
              itemCount: controller.noticeList.value.length,
              itemBuilder: (context, index) {
                return InkWell(
                  onTap: (){controller.clickNoticeDetail(controller.noticeList[index]);},
                  child: Container(
                    margin: EdgeInsets.only(left: 10, right: 10, top: 10),
                    padding: EdgeInsets.only(top: 15,left: 10,right: 10),
                    decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(8)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          controller.noticeList[index].title??"",
                          style: TextStyle(color: c_333333, fontSize: 15),
                        ),
                        SizedBox(
                          height: 15,
                        ),
                        Divider(
                          height: 1,
                        ),
                        SettingBar(
                          leftText: AppUtils.dateToString(controller.noticeList[index].updatedAt),
                          leftIconSpace: 0,
                          paddingHorizontal: 0,
                          leftTextSize: 12,
                          leftTextColor: c_999999,
                          rightIconSpace: 0,
                          rightTextSize: 12,
                          rightText: "查看详情",
                          rightIcon: SvgPicture.asset(R.assetsImgIcSvgRight),
                        )
                      ],
                    ),
                  ),
                );
              },
              shrinkWrap: true,
            );
          }),
        ),
      ),
    );
  }
}
